refactoring -- back to lab2