made into model/view/controller pattern