refortmat code to make gem-like