now line calculation as function