based on the code in https://github.com/o2platform/nwr/issues/33
based on the code in #33