ADDS type checking to word counting function