Add better error handling