Please check the attached document. The indentation got messed up when I pasted the code here.