I have made the data variable local to the function.