improved extension handling