refactored setup code into the local check()