this margin calculation works better