[detect_period] improve