fixing hist queries