fixed multiple class instance issue in JS