Improved Error Handling for prepare methods