Pretty close.  Some edge cases and actual casting to do