Added a more clear integration algorithm