rewrite mimetype detection