refactor code, add class