Fixed a bug in hasSpace()