Code from assignment 3