refactor main and update docs