Assignment 2 final code.