refactor to reduce repeats