refactor logic and state history