works with thread