move script out of js scoped block