Fixed error regarding empty arrays