update main.py to use low-level API