Function for integration