used each_with_index
add functions mocked up