Seems like this function should be in the model.