this is probably where vectorization would get a bit tricky, as this is a new dimension to the data. If it gets too tricky, feel free to start your for-loop here.