Safety Improvement Programs: a Planning Algorithm