Added basic error handling.