rebase and fixed to work with master