Improved Error Handling