update, refactor and documentation