Simulating 3D data

Optimized by two helper functions!