refactoring to a plugin model