bugfixing and new data generation function