Add security and error handling