refactor constructor, more api work