Working on code refactoring