Refactored all the codebase