remove repetitive code