fix to calculate padding size