fixed key error with try/except