added for loops to clean up code, simplified makefile generation