code refactoring to mime parser