try and catch errors in expand.py