code refactoring step 3