refactoring thread and added stint