Fix bug in LOOPS and ADDED two function + DEBUG MODE