refactor to use middle class