cs3113 assignment 3 (fixed a bug)