loop in 3d instaed of 2 in dim0