Refactored the If-tests.