refactoring of roles and states