put repeated code in includes, vectorized and parallelized functions