[scala] replaced filter and size calls with count