Refactoring code to delete duplicated code.
Refactoring code to delete duplicated code, step 2.
Refactoring code to delete duplicated code, step 3.
Refactoring code to delete duplicated code, step 4.