fix bug with alt being referenced before being defined