Fixed some bugs on the state
Improved output