Code Refactored
response changed to json from normal string
beautified js on http://jsbeautifier.org/