refactored into a plugin