fix bug with spacing loop