embed function updated to javascript code