add .gitignore
refactor some code