added refactored 2nd js