Code refactor and completed all tasks