Updated the dcosts function to run in parallel