Refactor code following revealing pattern