Fixing isValidCharacter function, improving how operation is set.