Fix keeping nearest line bug