Moved this function to model.js