Added some debug code for testing the function above. After the code was finished, the debug code was commented-out.