Using inheritance to avoid code repetition