refactored the codebase