refactor some code into master file