replace linked list with simple loop through input