Update readme.md and do some refactoring