added handling of indexlist as return type