abstract out the crossprod bit