Simplified code in hysteresis lab.