added js check on variable is defined or not