copied over code from tests, updated psd and doc