A pervert who performed a sex act in front of a mum and her children on a train and then followed them as they fled a station has been detained under the Mental Health Act.
A court heard the woman feared for her youngsters' safety and that she would not be able to protect them from Stefan Turansky.
The Slovakian had sat close to the family after boarding a London-bound train at Gillingham on July 29 last year.
CCTV image issued at time of appeal by British Transport Police
He first exposed himself before starting to perform an indecent act while staring at one of the children.
The group, who were described at the time as "shaken up", tried to move away but the 38-year-old followed them around the train.
When they eventually escaped at Gravesend, Turansky followed, continuing to carry out the sex act.
Maidstone Crown Court heard Turansky, of Mayfair Road, Dartford, had also targeted a young woman travelling on another train from Charing Cross to Gillingham that same day.
Turansky boarded at Dartford and sat across the aisle from the 26-year-old. She then noticed that he was exposing and touching himself while staring at her.
Turansky was later identified from CCTV footage and arrested. But less than a month later and while on bail he exposed himself on a bench in London's busy Leicester Square.
Turansky exposed himself on trains across north Kent. Library image
The court heard Turansky had also performed sex acts on himself in front of staff at the psychiatric unit where he has been held since January, although had not been charged with any offence.
Doctors treating him had also discovered from talking to his family back in Slovakia that he had a history of such behaviour, although he does not have previous convictions in either his native country or the UK.
Sentencing Turansky, Judge Philip Statman said it was necessary that while he received the treatment for his "emotionally unstable personality disorder", the public also needed to be protected.
It was for that reason that he imposed a "restriction order" under the Mental Health Act.
This means clinicians responsible for his care will decide when he is well enough to leave the medium secure unit.
They will then have to apply to the Justice Secretary, who will have overall responsibility for the decision to release him.
Judge Philip Statman at Maidstone Crown Court
Turansky, who sat in the dock flanked by two male nurses and was helped by an interpreter, admitted three offences of exposure and two of sexual activity in the presence of a child.
Judge Statman told him: "I have to consider what is to be done to ensure that you are helped in relation to your medical illness and that the community as a whole is protected.
"The need for a restriction order might be seen at first blush as draconian... but I am satisfied so I am sure, having regard to the nature of this offending conduct and your antecedents, that there is a risk of you committing further offences if set at large."
The court heard the two women later told police they felt "trapped" as for part of their journeys they were unable to escape Turansky.
"She (the mother) describes the real concern that she had that she might be unable to protect her children from you" - Judge Philip Statman
Referring to the mother's victim impact statement, Judge Statman remarked: "She describes the real fear engendered in both herself and her children when you followed them off the train, and she describes the real concern that she had that she might be unable to protect her children from you."
A condition of Turansky's disorder is lack of impulse control and his treatment will include the hospital equivalent of a sex offender programme usually given to those in prison.
A consultant psychiatrist said, however, that he would need psychological treatment for "a very long time" and that the long-term prognosis had to be "guarded".
Turansky will have to sign on the sex offender register indefinitely.