Assignment 3: Better implementation of task 7