Better errors

rewrote the line computation logic so it's actually correct