finaly fixed the bug

Watch for corect values when using loops