assignment 4, with loops!