refactor for threading

no single-line ifs.
space properly ){ -> ) {