Now using while-loop for integration.