refactoring, unique vars, speed test