Better variable validating to prevent certain errors