made pads faster
fixed algorithm