fixed empty array case