attempts to vectorize and unroll loop; compiles but causes segmentation fault

doesn't take care of edge cases