added backward serch for poles in the line extraction algorithm. TODO the code need a refactoring