create tempfiles using a generic function..clean up redunduncy..