Better security and error handling