Trying to sort out script