take daemon out of main code