move onChange to factory