Syntax error in buildQuery fixed