refactored output checking to be less complex