Removed commented code and broke the code up into functions