This function got a bit long. Could one refactor the search of the indel into its own function? (also better for testing)