Added a next pointer and fixed variable