fixed empty array bug