fixing line calculation algorithm

Fixes #15