optimizing user query