The code for the 2 functions