Improved extension matching

Improved extension matching