fix typos/line length issues
more code to ensure sufficient storage to a separate function, and revert to its original logic
remove unnecessary promise chain components
move package retrieval to its own function