Added listCollections helper and refactored code to correctly use new helper