Th gist of the two functions

Comments are to be added