refactored js inside catalog