refactoring and adding header file