fixed histogram bug, removed old code