Remove duplicate code and put the header in one single place