fixing a TypeError