added detection for spikes upwards as well as downwards