model and controller written