added catching of query