refactoring btDaemon.sh