fix js function snippet