deals with sapces in countmat function also