Assignment 3 implementation