fix a bug about index and margin