fixed a bug when adding spaces at the beginning