generalize to lib/utils.py and move get_space_id there