Added check for valid numeric vectors