Trying to get states to work
Refactoring