added basic implementation of indexOf that takes function as second param