fix a TypeError bug