Fixing js error. Running typeof check to remove .js error