added code to handle different first page margins