Revised a stupid while loop. Made more efficient.