WORKING VERSION.  can start with both state 1 and state 5