Refactored code for part 4 of exercise, Had issue with order of functions and commands.