re-wrote to work with multiple plugins