refactor for threading

space after while