simplify repetitive code