added Error handling on invalid query response from server