made some changes for CORS handling