I could be wrong but, I think the first instance of this needs moved up to the setup area.
int spacesAllowed = 1;