adding var to functions to try to fix for older browsers