Finally fixed the "malformed query ..." issue #2