Lab6 refactoring