Replace Closed Curves With Circle

 From:  Mindset (IGNITER)
8080.1 
Hello to All,

I am attempting to create a script to cleanup a vector trace of a half-tone image out of AI.
The goal is to loop through the closed curves and replace them with actual circles.
My attempt fails because all the new curves are getting created at the 0,0,0 origin rather than at the BoundingBoxCenter of the object to be replaced.
Also, how would one test if the object to be replaced is indeed a close curve and not already a circle?

Any help will be appreciated; this is my first attempt at scripting.
The is best forum in the world.

Thanks to everyone.
-- Mindset