A serial sex offender has failed in a bid to overturn his latest conviction.
David McMillan, 33, from Perth, was jailed for raping a 73-year-old woman in 1996 and was jailed in October 2009 for trying to lure a girl to his home.
McMillan admitted the offence and was given a lifelong restriction order with a minimum of 18 months in prison.
However, he claimed he had been given faulty legal advice before pleading guilty and appealed the decision.
McMillan said he believed his latest victim was 19 years old and not 14 when he approached her in breach of a Sexual Offences Prevention Order.
In an Appeal Court judgment, Lord Osborne said: "It is now well recognised that a conviction following upon a plea of guilty tendered with legal advice can only be quashed in limited circumstances."
He said the assumption McMillan made about the girl's age "could not amount to a 'reasonable excuse'."
Lord Osborne added: "It is quite plain from the circumstances of the case that the appellant made no inquiry of any kind in relation to the age of the complainer, but rather took the opportunity to try to make contact with her without any such inquiry.
"In all these circumstances we conclude that no miscarriage of justice has occurred and that therefore the appellant's appeal against conviction must be refused."
A Sopo (Sexual Offences Prevention Order) was previously granted against McMillan, after Tayside Police said he posed a "serious risk" and "imminent danger to all women."
McMillan, formerly of Glenearn Road, Perth, was already subject to the interim Sopo when he bombarded a vulnerable 14-year-old girl with calls between 28 July and 2 August in 2008.
He admitted breaching the Sopo by having unsupervised contact with a child through numerous phone calls and text messages.
McMillan had previously been convicted of a string of sexual offences.
He was jailed for life in 1996 after admitting raping a 73-year-old former teacher in her home.
However, in November that year, the Court of Criminal Appeal decided the original life sentence was excessive and cut it to nine years.
Following his release from prison in 2002, McMillan appeared in court on a number of occasions for breach of the peace offences that had a sexual element.
Background reports on McMillan found "there is a likelihood that he, if at liberty, will seriously endanger the lives, or physical or psychological well-being of members of the public."
Handing down a lifelong restriction order on McMillan, Judge Lord Brodie ruled that he should serve a minimum of 18 months in prison.
However the judge warned that did not mean he would be released then.
Such sentences allow the parole board to keep a prisoner in custody until they are satisfied that he, or she, no longer poses a danger to the public.