refactoring the run.js