Added condition to check key existnace

Hi,

Added check not through keyerror but return empty dictionary. Ans also removed unused import

Thanks