loop based on the passes
Added some comments