moderate refactoring. moved game logics from view to controller