tidier refactored