refactor reduce state