added models and necessary logic