refactor plugin loading