fix bug with PM and AM