while/if statements combined