gen_esme and gen_mc api implemented using cast