trying toms new stuff, but not working yet
checkpoint
vectorized a bunch of for-loops