'query_running' seems to be useless, you could invoke query_application_running right from here