How do I get rid of blank pages that occur when a condition is not met?