finished part 1, 2 and 3 of hw2 for CS169.1X