steps to compartmentalize idx viewer code