Refactoring
Changed check order