lab5 refactoring