Fully implemented, correct answer (though maybe not easiest way to do it)