Transferred over code from assignment 4