simplified and refactore csp.apply()