improve solution for inserting interval.