crashing when state variables become negative in ode