changed data structure and testing for ~ file