changed the syntax a little bit to use for loops