Improved file extension detect mechanism