Refactored the code in multiple categories