rewrote extension almost entirely, simplified