catch exception correctly