copied hansong's changes to assignment7