reordered some code in csp.js