added error event handler for main source query
corrected a syntax error in last commit