added functions to controllers; also added models