implemented APs saving into database