stabilized logger code, need to retest the sleep mode