Move logging outside the foreach