rewrorking my line splitting algorithm