handled a lot of query errors ( i hope )