added code to catch exception