daemonize option added

refactoring and daemonize option