pass around trains as linked list rather than array+size