Better filetype checking