fixed bug where data object has been used inside a function without passing it