Added code according to the assignment specification