update key, and add exception handler