refactoring error with data variable