Streamline type checks to avoid code duplication.