Cleaned up code. Combined sending code into a single for loop/function.