rewrite using Repa for parallel processing