Refactoring the code to take away most of the hard coded numbers