Everything looks like its functional but correctness is untested