updated with parallel processing