added padding handling