Error handling implemented