Modified error handling
Modified error handling