functions done. untested