adding header and refactoring