made Javascript to call Init API

Bug fixes to init API