fetch script now tests state before pulling and sets some variables useful downstream