asgn2 implementation