updated plugin with new logic and features