changed padding logic to something more sane