tweaking margin logic