Forked code from rdpeng snd made modifications for Assignment 2