Refactored the way we detect which type we need