Added the plugin and refactored some methods