add a real_directory helper function