fix zero array bug. still needs to be optimized