Slightly refactored.