Change method to detect files type