fixed file sorting bugs