Validating JS: Fixed suggested by @porcelli