Programming Assignment2 functions