improved script with logging ability, config file, and launh as a daemon