Refactor + thread