convert plugin into gem and add some fix