normalizes raw query