catch exception properly