updated parser

* added correct return value for empty query
* changed js code to fit our style guidelines