Added error handling with promises.