Initial attempt at combining the code. Compiles, but never finishes execution