fix ap calculations