improved identifyLine method