refactoring using strategy pattern