fix undefined key error