I have created the elisp code for problem3. This code was tested and works. I also removed some unused variables in the C code.