refactor of client with mvc in mind