proper filetype checking (not just by extension)