refactoring of linefinder and main