Adding check for running queries.