Refactoring code to delete duplicated code, step 5.