Fix value referenced before assigment error