refactor method to simplify