write test for step 4 and refactor for step 4