Implemented night threshold calibration