Completed the definition of the two functions