SEQ line optimization algorithm written