Updated code with linting

+Fixed JsLint warnings
+Replace undefined checks with simple check for object