Using median filter to remove noise now, seems to work well.