optimization code

includes header and footer