add daemon and logging fuction