added documentation and refactor methods