Fixed minor error in query and scan