fix the problem when get the period setting, and do a little refactor.