refactoring programme.js