added code to generate_data, also checked it on different orientations for dim 3