add docs
rename internal functions