Added better error handling to the query runner