Changed order of checks.