Added all model and controller logic