updated functions for assignment 2