massively improved plugin logic