implemented page rendering looping logic