Refactor using classes