Added ladder optimisation code - needs reworking