added check if both arrays are empty