refactored code and added new functions for catalog creation