better extension detection