Finish code refactor