updated javascript and added example