replace hist code with gist