Separating out mime logic