Fix issue#1 Add error handling