Changing to factory methd

remove methods from global scope that shouldn't be interacted with directly