Added Error handling