finally got the code working. the timing is still a little off...signals overflowing into the next frame