now go-routine safe
simplification and refactoring