refactor and fix godoc