Fix double generate bug