Refactor to use an explicit 'last' data state