Modified error handling