Fixed a bug when cheking pm/am