Improve the setDataFor function.