Added state 3 - 4 logic