Fixed some issues in the state conditions