runge-kutta method works correctly but it has to be optimized