Added check for None keys