some refinement and fix on ridho's plugin'