Added basic error handling