Solved Problem 7

Rearrange the auxiliary functions. Written these functions in the
beginning of the file.