added some excepton handling