updated controller to populate the database