handle exception properly