moved code to base_model