extract an if check into a method.