_.findIndex could simplify this part