There are plenty of if not something then panic code, refactor them with general functions, but try to avoid reflect.