fixed page_insert to work for all cases