refactoring pattern states