Optimize the onchange callback.