Add findIndex function - and a bug fix