improve padding and scaling