put header and footer at the right place