code from noc-py