refactored to make javascript development more mature

Change-Id: I260b992b98010524511d68ec025c931f44bdd052