fix bug as instructed in assignment 6