refactored codebase