more robust maxFilesSize implementation