add share button and re-factored some template code