Added basic error handling/robustness