Added docs and made into library function.