Solution for inset interval, reference from mitbbs