public void ResetButton(int currentFloor, ElevatorState status) { switch (status) { case ElevatorState.GoingDown: ButtonPressed.Where(command => command.Floor == currentFloor) .Where(command => command.Direction == Direction.Down).ToList <Command>().ForEach(command => ButtonPressed.Remove(command)); break; case ElevatorState.GoingUp: ButtonPressed.Where(command => command.Floor == currentFloor) .Where(command => command.Direction == Direction.Up).ToList <Command>().ForEach(command => ButtonPressed.Remove(command)); break; case ElevatorState.Waiting: ResetButton(currentFloor, ElevatorState.GoingUp); ResetButton(currentFloor, ElevatorState.GoingDown); break; } }