Refining Error Handling and Edge Cases