added states and cleaned up