creating getObj function to replace some indexOfObj uses