Updated implementation of CORS