Modified code to C++ (lol)
-Can compile now, but will require testing (tomorrow!)