almost working with the page logic