properly check daemon flag
Revert "properly check daemon flag"

This reverts commit adcb02b6ee694384e179617026071ab7a6aa55bd.
Revert "Revert "properly check daemon flag""

This reverts commit 0f53892d09b50c2fc1a692bdcc68cab6cd4e8ca4.