fixed TypeError bug