new version of histeresis tested on real data
some debugging code