Initial hand coded version for 2D multi dim dat ... need to fix vectorization now