Reducing code repetition