fix referenced before assignment