New make_temp function, which works better