Moved get_dir to own method