updated assignment 2 - segmentation error