added query on error