Rewrote to flex C++ muscles :D