Implemented the code for Project 4.