added nested loop and conditional

ran into a cat. Had to add a loop for dealing with a silly kitty.