change to async method and added setContentType