sync with code from statsh