added print to print query on error