Refactored code to clean and condense it
Refactored code to clean and condense it