NOTES TO CONSOLIDATED FINANCIAL STATEMENTS OF AMERICAN AIRLINES GROUP INC. (l) Maintenance  Materials and Repairs Maintenance and repair costs for owned and leased flight equipment are charged to operating expense as incurred  except costs incurred for (m) Selling Expenses (n) Share-based Compensation (o) Foreign Currency Gains and Losses Foreign currency gains and losses are recorded as part of other income  net within total nonoperating expense  net in our consolidated statements of operations. Foreign currency losses for 2018 and 2017 were $55 million and $4 million  respectively  and for 2016  foreign currency gains were $1 million. We account for our share-based compensation expense based on the fair value of the stock award at the time of grant  which is recognized ratably over the vesting period of the stock award. Certain awards have performance conditions that must be achieved prior to vesting and are expensed based on the expected achievement at each reporting period. The fair value of stock appreciation rights is estimated using a Black- Scholes option pricing model. The fair value of restricted stock units is based on the market price of the underlying shares of AAG common stock on the date of grant. See Note 15 for further discussion of share-based compensation. 95 Selling expenses include credit card fees  commissions  computerized reservations systems fees and advertising. Advertising costs are expensed as incurred. Advertising expense was $128 million  $135 million and $116 million for the years ended December 31  2018  2017 and 2016  respectively. maintenance and repair under flight hour maintenance contract agreements  which are accrued based on contractual terms when an obligation exists. With respect to contract receivables  reflected as accounts receivable  net on the accompanying consolidated balance sheet  these primarily include receivables for tickets sold to individual passengers through the use of major credit cards. These receivables are short-term  mostly settled within seven days after sale. Bad debt losses  which have been minimal in the past  have been considered in establishing allowances for doubtful accounts. The air traffic liability principally represents tickets sold for future travel on American and partner airlines  as well as estimated future refunds and exchanges of tickets sold for past travel. The balance in our air traffic liability also fluctuates with seasonal travel patterns. The contract duration of passenger tickets is one year. Accordingly  any revenue associated with tickets sold for future travel will be recognized within twelve months. For 2018  $3.1 billion of revenue was recognized in passenger revenue that was included in our air traffic liability at December 31  2017. The balance of the loyalty program liability fluctuates based on seasonal patterns  which impact the volume of mileage credits issued through travel or sold to co-branded credit card and other partners (deferral of revenue) and mileage credits redeemed (recognition of revenue). Changes in loyalty program liability are as follows (in millions): Balance at December 31  2017 $ 8 822 Deferral of revenue 3 083 Recognition of revenue  (1) (3 366 ) Balance at December 31  2018  (2) $ 8 539 (1) Principally relates to revenue recognized from the redemption of mileage credits for both air and non-air travel awards. Mileage credits are combined in one homogenous pool and are not separately identifiable. As such  the revenue is comprised of miles that were part of the loyalty program deferred revenue balance at the beginning of the period  as well as miles that were issued during the period. (2) Mileage credits can be redeemed at any time and do not expire as long as that AAdvantage member has any type of qualifying activity at least every 18 months. As of December 31  2018  our current loyalty program liability was $3.3 billion and represents our current estimate of revenue expected to be recognized in the next twelve months based on historical trends  with the balance reflected in long-term loyalty program liability expected to be recognized as revenue in periods thereafter.