Adding Error handling