rewrote signature generation code to use no memory