Modify all() to work with nested input arrays