using arrays and loops