Eliminate repetition (solves exercise 3.1)