Made exercise 2 more efficient