finish refactoring for clarity