move some code from single_page