refactor exersice