Build the code for the functions and added comments

Both functions should work as described now