add assignment2 functions