fixing result array bug