refactor code to make cleaner, update README.