Alternate Solution - Fixing Enemy Formation

I came up with my own way when you asked us to make the formation move. This bad boy could last up to more than a million!

using UnityEngine;
using System.Collections;

public class EnemySpawner : MonoBehaviour 
{
public GameObject enemyPrefab;
public float width = 10f;
public float height = 5f;
public float speed = 1f;
public float padding = 1f;

private float xmin;
private float xmax;
private bool inverse = false;

void Start () 
{
	//defying variables
	//Border variables
	float distance = transform.position.z - Camera.main.transform.position.z;
	Vector3 leftmost = Camera.main.ViewportToWorldPoint(new Vector3 (0, 0, distance));
	Vector3 rightmost = Camera.main.ViewportToWorldPoint(new Vector3 (1, 0, distance));
	xmin = leftmost.x + padding;
	xmax = rightmost.x - padding;

	//Instantiating enemies
	foreach (Transform child in transform)
	{
		GameObject enemy = Instantiate (enemyPrefab, child.transform.position, Quaternion.identity) as GameObject;
		enemy.transform.parent = child;
	}
}

void OnDrawGizmos()
{
	Gizmos.DrawWireCube (transform.position, new Vector3(width, height, transform.position.z));
}

void Update () 
{
	if (transform.position.x == xmin)
	{
		transform.position += new Vector3(speed * Time.deltaTime, 0, 0);
		inverse = true;
	}

	else if (transform.position.x == xmax)
	{
		transform.position += new Vector3(-speed * Time.deltaTime, 0, 0);
		inverse = false;
	}
	else 
	{
		if (inverse == false)
		{
			transform.position += new Vector3(-speed * Time.deltaTime, 0, 0);
		}
		if (inverse == true)
		{
			transform.position += new Vector3(speed * Time.deltaTime, 0, 0);
		}
	}
	//setting border
	float newx = Mathf.Clamp (transform.position.x, xmin, xmax);

	transform.position = new Vector3 (newx, this.transform.position.y, this.transform.position.z);
}
}

Yep, using the code from our previous game (the Mathf.Clamp and the newx used to specify the Vector3 value for x) is what made it so I didn’t have the issue either.