Move check for proxy outside of loop.