Updated the functions and tested them