1st version of reworked addPages agent