Fixed issue with global js variables