Improve the "setDataFor" function.