move logic into daemon thread