Greg's refactor