```target``` has no default value, maybe here it's None, and len(None) will raise ```TypeError: object of type 'NoneType' has no len()```,
So I suggest here to use ```if targer is None or len(target) == 0:```, what do you think?