updated stack.js slolution