Added code and algorithm to do multiple passes.