added daemon code