Simplifying code a little to resume work on plugin