the guts of the js working