move check of else statement into conditional