for loop moved from main to individual functions
just cleaned up the code a bit