code refactoring - thread pause