fixed saving APs to database