update and refactor plugin to work with recent joomla version