refactor all to mvc pattern