Modified code to allow CORS requests