make no assumptions about length of depth array