refactor to simplify