Small refactor of get_by_type method