Fix javascript errors when try to evaluate undefined variables