refactor formModelFields to a function