Wrote in actual code

May or may not compile, but if it doesn't the error is minor syntax.  Logic is sound.