Refactor thread as decorator