Added code to prevent completely empty pages