refactor code to get current branch name