some preparing code for pages