refactor assignment2