refactoring to profile the method and thread execution