Refactoring run_algos
general refactoring