fixed error in daemon func