refactor to make state setter a private method