Fix code repetition