fixed a bug in ap