defining success bcause ''referenced before assignment' error