testing states and refactoring