moved logic into a plugin