split-up function to model.js