how to get indexof object: reference vs memory
method to break the for loop