Adding some error handling