Updated program so it doesn't do excessive file retrieval