dry up code and simplify