fixed try except issue where key value was incorrect