updated with arrays and for loops