refactor code, update README, update examples