refactored small pieces