** Added proper error handling