Just want to add Items to List and return it

This is always returning empty

def getPoints(panels:var[])
{
	names = panels.GetParameterValueByName("Panel Name");
	levels = panels.GetParameterValueByName("Level");
	levelNames = levels.GetParameterValueByName("Name");
	count = List.Count(levelNames);
	nCount = List.Count(names);
	xPts = [];
	current = List.GetItemAtIndex(levelNames, 0);
	increment = 0;

	[Imperative]
	{
		for(i in count)
		{
			if(levelNames[i] != current)
			{
				increment = increment + 1;
				current = List.GetItemAtIndex(levelNames, i);
			}
			xPts = List.AddItemToEnd(Point.ByCoordinates(0,increment * 0.5,0), xPts);
		}
	}
	return = xPts;
};

Is it imperative to use code like you are? There are built in nodes that will allow you to add data to lists at specified indices, as well as packages with nodes that will always add content to the end or beginning of the list.

I will try with Nodes, was trying to make it concise, but maybe I am missing something.