updated javascript to fix loading issue