Trying to fix indices return value problem