refactored js and made a name change: