updated ap file to loop tthrough files