fixed wrapping of intervals