updated functions as per programming assigment 2 instructions