Fixing potential bug on margin