made @trains variable into an instance variable so it is visible across files