Handle exception properly