Move folder select into function