Refactored some code into variables