Edited lss - added exit conditions