Changed C code to Pseudo code