Improvement on integrate code