fix calculate start and end point bug