Unrelated to this bug but since you touched this line `data=None` and `if not data: data={}` within the function