some modularization of my plugin