remove redudant "query" state, trim query