refactoring and test before turnin