fix end point problem