Initial commit
backup before refactor
Refactored, may still has lots of bug