changed lenght param to end instead