Assignment 3 function