add condition checking to avoid keyError Exception