Move some function and database call to the Daemon.py