Refactored according to pair review