fixed daemonize code