fixed integration loop so that it doesn't overwrite initial data