Improved extension matching

Improves extension matching