refactoring get_model_data as it was getting too long