reduce duplicated code. add previous value init in startup().