fix betweenEnd == nil case