tried to refactor