refactoring , added some parallelization suport