fix random problem and template