Implement margin handling