Move the init function to the top fo the file. Switch from array_pop() to array_shift() when not email ID is present when loading a page.