Updated by Xiaoyu Liu for Programming assignment 2