some bugs fixed for the margin