mad changes to for loop and added variable