changed integrate_for_time to exactly integrate the time period (dt is slightly changed if neccessary)