refactor loading script into sort of separate modules