Added Gaurav's code, made a couple edits to it.