refactor a code from exemple plugin