reorganizing into gimi_util.py