restructured if(local) blocks so now there is just a single computational block, with if(local) blocks in front and in back to start and end parallel processing