refactor using mvc