Fix bugs in assignment 4.