refactoring code/modularising