refactored threading mechanism to memory gently