added CORS header, and refactoring