rewrote file_exists function