very simple algorithm implemented that appears to work - next stage is to make it more fancy