Refractor code to make scanner plugin work