Fixed keyerror issue