some queries optimization