reorganize padding handling