moved the duplicated sharing code to requirejs module