it has been figured out. got a working script for this thanks to Collective.