rename variable from cur to len