Updated script to work correctly on MIST