copied from wildgoose