added more untested code.