Some error handling in the code