fix query formatting