fixed generate twice bug