separated out common dir functions