added refactored code for collection