add rebase and minor refactor