updated sorting and parsing of files