added proper dimension wise iteration (think for ufuncs in numpy