Refactored the pass 2 method