first working versions with 3 states