Trying to fix stack issue with js