Externalized threading to main.py