Remove debug
Fix function scope