Refactored the rest of the code into handlers