Fixed line filtering algorithm

- now algorithm filters lines better
- still unknown if works properly