AM_PM bug fix