added advanced mime handling