bug fix on construct query