Final version for HW1-2.