Fix start line and end line point algorithm