updated javascript structure