refactoring code and reorganising files