removed unnecessary promise from optimizeFile function