Added error handling.