error checking for empty array