Updated it to work in any JS file
Updated for correct scope for testing snippets