add gitignore
add comments and refactor a little