Removed some bugs in integration method