improved line approach algorithm