Fix: calcuration of padding and margin