Assignment 2, code for two functions