SALEM – Ernesto Gonzalez will remain in custody even after a judge dismissed charges against the Lynn man for allegedly kidnapping his 5-year-old son Giovanni in 2008.Gonzalez, who was found mentally incompetent to stand trial, has been committed to a state mental-health facility and is held without bail on an assault-and-battery charge stemming from an alleged jailhouse incident.”The judge was following the law, and I believe he applied it correctly in this case,” defense attorney Lance Sobelman, standing in for his father, attorney Russell Sobelman, said after the ruling Thursday.State law allows defendants who have been declared incompetent to stand trial to file for dismissal of charges if the defendant has served at least half the maximum sentence he or she would have received if convicted.Giovanni was reported missing by his mother, Daisy Colon, on Aug. 17, 2008 after she went to pick up the child from a pre-arranged visit at his father’s apartment on Brightwood Terrace.Colon found no one at the apartment and, after attempting for several hours to locate her son and Gonzalez, called police.Gonzalez denied being with Giovanni that weekend, but witnesses testified to seeing the two together. Gonzalez then told a reporter he killed and dismembered the boy’s body, and police later found traces of the boy’s blood on a knife, on the floor and on a cleaning can in the apartment. But Giovanni has never been found. Colon has previously told The Daily Item she thinks Gonzalez may have conspired with an accomplice to kidnap and transport Giovanni out of the country, then hide him until father and son could be reunited.Gonzalez, 42, was charged with parental kidnapping and misleading a grand jury. He has been confined or hospitalized since the date Giovanni was reported missing.Russell Sobelman filed for the charges to be dismissed in November, arguing Gonzalez has been held for more than five years – half of the 10-year sentence for a conviction of misleading investigators.But Essex Assistant District Attorney Jean Curran argued Gonzalez had only been found incompetent for trial last year. A judge only accepted that finding in October. Curran argued the time credited under the statute should be calculated from when Gonzalez was found incompetent, not originally incarcerated ? particularly if mental-health experts thought Gonzalez might eventually be able to stand trial.Judge John Lu continued the motion for dismissal several times during the past month, awaiting an official calculation from the Department of Correction of the time Gonzalez would be credited as well as an updated mental-health evaluation of the defendant.Both were delivered Thursday and were referenced in Lu’s ruling.Lu noted in court the Department of Correction at Bridgewater State Hospital calculated Gonzalez was eligible on Aug. 17, 2013 to file for the charges to be dismissed.”Because Mr. Gonzalez has been adjudicated as incompetent and has been confined for over five years, more than one half of the maximum potential sentence for the most serious charge against him, the motion to dismiss must be allowed,” Lu wrote.Lu also wrote that “numerous very recent mental-health records? all support a finding of not competent.” Lu cited records reporting Gonzalez has disorganized thinking, hears voices telling him to kill himself and others and “experiences psychosis including hallucinations and delusions.”Gonzalez was present in the courtroom but appeared to register no change in emotion as Lu announced that he would dismiss the charges.”While the charges related to the disappearance of Giovanni Gonzalez have been dismissed, our efforts to locate him have not ceased,” Essex District Attorney Jonathan Blodgett said in a statement after the ruling. “We continue to follow up on each and every lead that is presented to us and we will continue to do so.”Ernesto Gonzalez next returns to court April 16 for a mental-health status hearing on the assault-and-battery charge. In th