Refactored the codebase