refactoring, add comments, add options