Andrew's updates to the functions file