Minor refactoring

Minor reordering of checks