Middleware method to get the current selected train