Refactor to reduce state