- optimize function for displaying per page