Adapting the script to work both with hooks and plugins part 1