refactor to reduce state mutablity