changed to pointer template in GenerateData, this is a cleaned-up version given to Amin