use a more clever way to find the correct mime type